﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bussiness;

namespace WebApplication
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadKhachHang();
            }

        }
        public void LoadKhachHang()
        {
            IUnitOfWork iunitfwork = new EFUnitOfWork();
            KHACHHANGRepository repository = new KHACHHANGRepository(new EFRepository<KHACHHANG>(), iunitfwork);
            IQueryable<KHACHHANG> objkhachhang = repository.All();
            comboboxs.DataSource = objkhachhang;
            comboboxs.DataValueField = "MAKH";
            comboboxs.DataTextField = "TENKH";
            comboboxs.DataBind();
            comboboxs.Items.Insert(0, new ListItem { Text = "---Chọn khách hàng---", Value = "0" });

        }
        protected void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtkq.Value = comboboxs.SelectedValue;
        }
    }
}